package com.dream.myqiyi.db;

import java.sql.SQLException;

import com.dream.myqiyi.dao.TagModel;
import com.j256.ormlite.dao.BaseDaoImpl;
import com.j256.ormlite.dao.Dao;
import com.j256.ormlite.dao.DaoManager;
import com.j256.ormlite.support.ConnectionSource;
import com.j256.ormlite.table.TableUtils;

public class TagDaoImpl extends BaseDaoImpl<TagModel, String> implements TagDao {
	Dao<TagModel, String> tagDao;
	
	public TagDaoImpl(ConnectionSource connectionSource) throws SQLException {
		super(connectionSource, TagModel.class);
	}
	
	public void performDBOperations(ConnectionSource connectionSource) throws SQLException {
		tagDao = DaoManager.createDao(connectionSource, TagModel.class);
		
		// create table
		TableUtils.createTableIfNotExists(connectionSource, TagModel.class);
	}
	
	public Dao<TagModel, String> getDao() {
		return tagDao;
	}
}
